package com.hucii.app.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hucii.app.R;

public class BaseLayout extends RelativeLayout {

	private TextView tv_header;
	public View header_bar;
	public View bottom_bar;
	private TextView tv_header_left;
	private TextView tv_personal_data;
	private TextView tv_message;
	private TextView tv_exit;
	


	public TextView getTv_header_left() {
		return tv_header_left;
	}

	public TextView getTv_personal_data() {
		return tv_personal_data;
	}

	public TextView getTv_message() {
		return tv_message;
	}

	public TextView getTv_exit() {
		return tv_exit;
	}

	public BaseLayout(Context context, int layoutResourceId) {
		super(context);
		LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		header_bar = layoutInflater.inflate(R.layout.header, null);
		header_bar.setId(R.id.header_bar);
		tv_header = (TextView) header_bar.findViewById(R.id.tv_header_middle);

		tv_header_left = (TextView) header_bar.findViewById(R.id.tv_back);
		tv_personal_data = (TextView) header_bar.findViewById(R.id.tv_personal_data);
		tv_message = (TextView) header_bar.findViewById(R.id.tv_message);
		tv_exit = (TextView) header_bar.findViewById(R.id.tv_exit);

		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		addView(header_bar, params);
		
		
		
		//RelativeLayout.LayoutParams params3 = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
		//params3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		//addView(bottom_bar, params3);
		
		View view = layoutInflater.inflate(layoutResourceId, null);
		RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
		params2.addRule(RelativeLayout.BELOW, R.id.header_bar);
		//params2.addRule(RelativeLayout.ABOVE, R.id.rl_bottom_bar);
		addView(view, params2);
	}


	public void setTitle(String title) {
		if (title != null) {
			tv_header.setVisibility(View.VISIBLE);
			tv_header.setText(title);
		} else {
			tv_header.setVisibility(View.GONE);
		}
	}
}
